different ways to create an object in java